(function (win, dow) {
	let url = window.location.search,
	    urlId = url.slice(url.indexOf("=") + 1),
			swiper = mui("#slider .banner")[0],
			introduce = mui(".detail-wrap .introduce")[0];
	function init () {
		packageDetail()
	}
	// 获取包详情数据
	function packageDetail() {
		let url = 'http://localhost:8080/pawnShop/m/getMGoodsOne'
		mui.ajax(url, {
			 type: "POST",
			 data: JSON.stringify({"id": urlId}),
			 dataType: 'json',
			 headers: {
			 	'Content-Type': 'application/json'
			 },
			 success: function (data) {
				 console.log(data);
				 if(data.code === "200") {
					 let detail = data.data,
					     swiperList = detail.imgs,
							 imgsLen = swiperList.length,
							 imgsCon = '';
					 for(let i = 0; i < imgsLen; i++){
						 let div = `
								<div class="mui-slider-item">
									<a href="#">
										<img src="${swiperList[i]}">
									</a>
								</div>
						 `
						 imgsCon += div;
					 }
					 let imgFirst = `
						<div class="mui-slider-item mui-slider-item-duplicate">
							<a href="#">
								<img src="${swiperList[0]}">
							</a>
						</div>
					 `
					 let imgLast = `
					    <div class="mui-slider-item mui-slider-item-duplicate">
					    	<a href="#">
					    		<img src="${swiperList[imgsLen-1]}">
					    	</a>
					    </div>
					 `
					 let sale_price = '';
					 if (detail.sale_price === 0) {
						 sale_price = detail.price_font.slice(detail.price_font.indexOf(":") + 3);
						 if (detail.price_font === "") {
							 sale_price = '售罄'
						 }
					 } else {
						 sale_price = detail.sale_price
					 }
					 let packageInt = `
							<p class="introduce-con">
								<span class="rmb">￥</span><span class="sprice">${sale_price}</span>
								<span class="old label">${detail.state}</span>
								<span class="exclusive label">新人专享</span>
							</p>
							<p class="original">￥${detail.price_font}</p>
							<p class="package-name">${detail.title}</p>
					 `
					swiper.innerHTML = imgFirst + imgsCon + imgLast;
					console.log(packageInt)
					introduce.innerHTML = packageInt
				 } else {
					 alert('请求错误')
				 }
			 },
			 error: function (err) {
				 alert('请检查您的网络')
			 } 
		})
	}
	init()
}(window, document))